$(document).ready(function() {
	var KEY_AUTH_TOKEN = 'authToken';
	var authToken = $.cookie(KEY_AUTH_TOKEN);

	// 获取用户名
	var url = "/user/info/" + authToken;
	syncGet(url,
		function(email) {
			$('#username').text(email);
		},
		function(result) {
			if (result.status == '403') {
				alert('您的请求过于频繁，请求已被拒绝');
			} else {
				$(location).attr("href", "login.html");
			}
		});

	// 点击退出登录
	$("#logout").click(function() {
		$.removeCookie(KEY_AUTH_TOKEN, {
			path: '/'
		});
		$(location).attr("href", "login.html");
	});

});
